package com.hs.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hs.entity.Fm;
import com.hs.mapper.FmMapper;
import com.hs.service.FmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FmServiceImpl implements FmService {
    @Autowired
    private FmMapper fmMapper;
    @Override
    public int addFm(Fm fm) {
        return fmMapper.addFm(fm);
    }

    @Override
    public int deleteFm(int id) {
        return fmMapper.deleteFm(id);
    }

    @Override
    public int updateFm(Fm fm) {
        return fmMapper.updateFm(fm);
    }

    @Override
    public Fm getFmById(int id) {
        return fmMapper.getFmById(id);
    }

    @Override
    public PageInfo<Fm> getFmByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Fm> fmByPage = fmMapper.getFmByPage();
        PageInfo<Fm> pageInfo = new PageInfo<>(fmByPage);
        return pageInfo;
    }
}
